//a.js===================

const obj1 = {
  a: ['1', '2', '3'],
  b: ['4', '5', '6'],
  c: ['10'],
  //普通方法
  each: function (callback) {
    const arr = [].concat(this.a, this.b, this.c);
    for (const item of arr) {
      callback(item)
    }
  },

  //迭代器方法
  // [Symbol.iterator]: function () {
  //   const arr = [...this.a, ...this.b, ...this.c];
  //   let index = 0;
  //   return {
  //     next: function () {
  //       return {
  //         value: arr[index],
  //         done: index++ >= arr.length
  //       }
  //     }
  //   }
  // }

  //生成器方法
  [Symbol.iterator]: function* () {
    const arr = [...this.a, ...this.b, ...this.c];
    for (const item of arr) {
      yield item
    }
  }
}

//b.js===================

obj1.each(i => console.log('each', i));

for (const item of obj1) {
  console.log(`for-of`, item);
}